package com.hktf.moedokilock.activity;

import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.hktf.corelib.jsonbean.response.CommonResult;
import com.hktf.corelib.utils.CommUtils;
import com.hktf.moedokilock.R;
import com.hktf.uilib.app.BaseActivity;
import com.hktf.uilib.callback.BaseCallBackNew;
import com.hktf.uilib.engine.DriverEngine;
import com.hktf.uilib.utils.DlgUtils;
import com.hktf.uilib.utils.ToastUtils;
import com.lzy.okgo.model.Response;

public class LogOffActivity extends BaseActivity implements OnClickListener, BaseQuickAdapter.OnItemChildClickListener, BaseQuickAdapter.OnItemClickListener {


    private TextView tvAdd;
    private int flag;
    private String title;

    @Override
    public boolean isLayoutFitsSystemWindows() {
        return false;
    }
    @Override
    public int getLayoutResID() {
        return R.layout.act_logoff;
    }



    @Override
    public void onClick(View v) {
        int id = v.getId();
        CommUtils.closeInput(v);
        if (id == R.id.tv_add) {
            modifyBeiz();
        }else if (id == R.id.titlebar_back) {
            finish();
        }
    }

    private void modifyBeiz() {
      DlgUtils.showDlgNew(this,
              null,
              getString(com.hktf.uilib.R.string.logoff_tip2),
              getString(com.hktf.uilib.R.string.ok),
              getString(com.hktf.uilib.R.string.cancel),
              new DlgUtils.MyListener() {
                  @Override
                  public void onConfirm() {
                      logoff();
                  }

                  @Override
                  public void onCancel() {

                  }
              }
              );
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
    }


    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onStop() {
        super.onStop();
    }

    @Override
    public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
    }

    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {

    }

    private TextView tv_tip;

    public void initView() {
        tv_tip=findViewById(R.id.tv_tip);
        tvAdd = (TextView) findViewById(R.id.tv_add);
        tvAdd.setOnClickListener(this);
        setTitle(getString(com.hktf.uilib.R.string.logoff));
        setBackClick();

    }

    @Override
    public void initListener() {

    }

    @Override
    public void initData() {

    }

    private void logoff() {
        showLoadingSend();
        DriverEngine.userLogoff(new BaseCallBackNew<CommonResult>(CommonResult.class){
            @Override
            public void onSUCCESS(Response<CommonResult> response) {
                DlgUtils.disMissDlg();
                ToastUtils.showToast(LogOffActivity.this,getString(com.hktf.uilib.R.string.logoff_success));
                startActivity(new Intent(LogOffActivity.this, LoginActivity.class));

            }
        });
    }
}
